package com.eonmind.knowledge.provider;

import com.eonmind.common.contract.data.response.ResponseEntity;
import com.eonmind.common.provider.entity.knowledge.Knowledge;
import com.eonmind.knowledge.contract.api.KnowledgeFeignService;
import com.eonmind.knowledge.contract.dto.KnowledgeData;
import com.eonmind.knowledge.mapper.KnowledgeMapper;
import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RestController;

/**
 * 知识库Feign服务提供者
 *
 * @author Xujie
 * @since 2025/6/7 10:54
 **/
@RestController
public class KnowledgeFeignProvider implements KnowledgeFeignService {
    @Resource
    private KnowledgeMapper knowledgeMapper;

    @Override
    public ResponseEntity<KnowledgeData> queryKnowledge(Long knowledgeId) {
        Knowledge knowledgeById = knowledgeMapper.getKnowledgeById(knowledgeId);
        KnowledgeData knowledgeData = new KnowledgeData();
        BeanUtils.copyProperties(knowledgeById, knowledgeData);
        return ResponseEntity.success(knowledgeData);
    }
}
